<?php

namespace Sensio\Bundle\TrainingBundle\Service;

use Sensio\Bundle\TrainingBundle\Contact\Contact;

class ContactService
{
    private $mailer;
    private $recipient;

    public function __construct(\Swift_Mailer $mailer, $recipient)
    {
        $this->mailer = $mailer;
        $this->recipient = $recipient;
    }

    public function sendEmail(Contact $contact)
    {
        $message = \Swift_Message::newInstance($contact->subject, $contact->message)
                ->setTo($this->recipient)
                ->setFrom($contact->sender);

        $this->mailer->send($message);
    }

}